﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharpShare.Configuration;
using System.Configuration;
using SharpShare.Storage.Filter;
using System.ComponentModel;

namespace SharpShare.Storage.Zip.Configuration {
    public class ZipArchiveBrowseStorageProviderConfigurationElement : StorageProviderElement {

        [ConfigurationProperty("baseStorageProvider")]
        [TypeConverter(typeof(StorageProviderNameConverter))]
        [DisplayName("Source Storage Provider")]
        public string BaseStorageProvider {
            get {
                return (string)this["baseStorageProvider"];
            }
            set {
                this["baseStorageProvider"] = value;
            }
        }

        public override IStorageProvider CreateStorageProvider(IConfigurationContext context) {
            IStorageProvider baseProvider = context.GetStorageProvider(this.BaseStorageProvider);

            ZipArchiveBrowseFilter filter = new ZipArchiveBrowseFilter();
            FilteredStorageProvider filterProvider = new FilteredStorageProvider(baseProvider, filter);

            return filterProvider;
        }
 
    }
}
